<template>
  <div class="app-container">
    <search-form v-if="fieldList"
      :fields="fieldList"
      v-show="showSearch"
      @submit="handleQuery"
      @cancel="resetQuery"
    ></search-form>

    <!-- 工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5" v-if="moduleInfo.exportable == 'Y'">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['run:'+moduleInfo.code+':export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <!-- 表格 -->
    <el-table
      v-loading="loading"
      :data="dataList"
    >
      <el-table-column type="selection" width="55" align="center" />
      <template v-for="(f, i) in fieldList">
        <el-table-column
          :label="f.label"
          align="center"
          :prop="f.code"
          :key="i"
          v-if="f.list == 'Y' && f.type == 'checkbox'"
        >
          <template slot-scope="scope">
            {{ dictLabel(f.code, scope.row[f.code])}}
          </template>
        </el-table-column>
        <el-table-column
          :label="f.label"
          align="center"
          :prop="f.code"
          :key="i"
          v-else-if="f.list == 'Y' && f.type == 'radio'"
        >
          <template slot-scope="scope">
            {{ dictLabel(f.code, scope.row[f.code])}}
          </template>
        </el-table-column>
        <el-table-column
          :label="f.label"
          align="center"
          :prop="f.code"
          :key="i"
          v-else-if="f.list == 'Y' && f.form == 'date'"
        >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row[f.code], '{y}-{m}-{d}') }}</span>
        </template>
        </el-table-column>
        <el-table-column
          :label="f.label"
          align="center"
          :prop="f.code"
          :key="i"
          v-else-if="f.list == 'Y' && f.form == 'datetime'"
        >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row[f.code]) }}</span>
        </template>
        </el-table-column>
        <el-table-column
          :label="f.label"
          align="center"
          :prop="f.code"
          :key="i"
          v-else-if="f.list == 'Y'"
        />
      </template>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
            >查看</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="pager.page"
      :limit.sync="pager.limit"
      @pagination="getList"
    />

    <!-- 添加或修改对话框 -->
    <form-dialog v-if="fieldList"
      @submit="submitForm"
      @cancel="cancel"
      :data="formData"
      :action="formAction"
      :title="formTitle"
      :fields="fieldList"
    ></form-dialog>

  </div>
</template>

<script>
import ListMixin from "./list"
import FormDialog from "./form"
import SearchForm from "./search"

export default {
  name: "RunQuery",
  components: {
    FormDialog, SearchForm
  },
  dicts: [],
  mixins: [ListMixin],
  data() {
    return {
    };
  },
  methods: {    
    
  }
};
</script>

<!--
列表字段的处理逻辑如下：
1、按排序展示字段，可设置列表不展示，具体内容按类型进行格式化
2、普通内容原样展示
3、日期和日期时间自动格式化为 yyyy-MM-dd和yyyy-MM-dd hh:mm:ss
4、支持图片预览
5、支持字典转义
-->